import 'package:flutter/material.dart';
import 'package:silver_flutter/widget/authed.dart';
import 'package:silver_flutter/widget/book_list.dart';

class BookshelfPage extends StatefulWidget {
  BookshelfPage({Key key}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return new _BookshelfPageState();
  }
}

class _BookshelfPageState extends State<BookshelfPage> {
  @override
  Widget build(BuildContext context) {
    return new DefaultTabController(
      length: 2,
      child: Scaffold(
        appBar: AppBar(
          title: Text('书架'),
          bottom: TabBar(
            tabs: <Widget>[
              Tab(
                text: '收藏',
              ),
              Tab(
                text: '历史',
              ),
            ],
          ),
        ),
        body: TabBarView(children: <Widget>[
          new Authed(
            builder: (context) => new BookList(fetchPath: '/user/favourites'),
          ),
          new Authed(
            builder: (context) => new BookList(fetchPath: '/user/history'),
          )
        ]),
      ),
    );
  }
}
